package model

import (
	"github.com/google/uuid"
	"gorm.io/gorm"
)

type Product struct {
	Id            string  `json:"id" gorm:"primaryKey;type:varchar(36);column:id;"`
	ProductName   string  `gorm:"type:varchar(255);not null;column:product_name;" json:"product_name"`
	ProductPrice  float64 `gorm:"type:float64;not null;column:product_price;" json:"product_price"`
	ProductTypeId string  `gorm:"type:varchar(36);not null;column:product_type_id;" json:"product_type_id"`
	ProductDesc   string  `gorm:"type:varchar(255);not null;column:product_desc;" json:"product_desc"`
	CreatedAt     int64   `json:"created_at" gorm:"type:int64;column:created_at;not null;"`
}

func (Product) TableName() string {
	return "product"
}

func (u *Product) BeforeCreate(tx *gorm.DB) (err error) {
	u.Id = uuid.NewString()
	return
}
